/**
 * reducer
 */
import Cookies from 'js-cookie'

import {
    USER_INFO
} from '@/action'

//init
let initStore = {
    //用户信息
    userInfo: null,
}

export default function (state = initStore, action) {
    switch (action.type) {
        case USER_INFO:
            return Object.assign({}, state, {
                userInfo: action.data || JSON.parse(Cookies.get('userInfo'))
            })
        default:
            return state
    }
}